<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class AccountControl {

    private $CI = null;

    public function __construct() {
        $this->CI = & get_instance();
        if ($this->isConnected() == false) {
            if ($this->CI->uri->uri_string() != 'account/login' && $this->CI->uri->uri_string() != 'account/process')
                redirect('account/login');
        }
        if ($this->isConnected() == true) {
            if ($this->CI->uri->uri_string() == 'account/login')
                redirect(base_url());
        }
    }

    private function isConnected() {
        $this->CI->load->library('session');
        
        //var_dump($this->CI->session->userdata());
        if ($this->CI->session->userdata('valid')) {
            return true;
        } else {
            return false;
        }
    }

    

}

?>
